﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;

namespace ProgNetComponents.Tools
{
    /// <summary>
    /// Tools for file operations
    /// </summary>
    public static class FileTools
    {
        /// <summary>
        /// Gets encoding of a file
        /// </summary>
        /// <param name="fileName"></param>
        /// <returns></returns>
        public static Encoding GetFileEncoding(string fileName)
        {
            Encoding e = null;
            using (var r = new StreamReader(fileName, detectEncodingFromByteOrderMarks: true))
            {
                e = r.CurrentEncoding;
            }
            return e;
        }
    }
}
